<%@page import="java.lang.reflect.Type"%>
<%@page import="java.util.ArrayList"%>
<%@page import="bean.Student"%>
<%@page import="java.util.List"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>学生信息</title>
</head>
<body>
	<%@include file="teacher_head.jsp"%>
	<div class="container">
		<div class="row">
			<div class="form-inline">
				<img src="../../resource/teacher.jpg" class="img-rounded imgstyle" />
				<h1>
					<strong>上机考试管理</strong>
				</h1>
			</div>
		</div>
	</div>
	<br>
	<div class="container divcontainerstyle">
		<h2>添加单个学生</h2>
		<form action="../../servlet_addstudent_teacher">
			<div class="form-inline">
				<input type="text" name="addstudentnumber" placeholder="学号*"
					class="form-control"> <input type="text"
					name="addstudentname" placeholder="姓名*" class="form-control">
				<input type="text" name="addclassroom" placeholder="班级*"
					class="form-control">
				<button type="submit"
					class="btn btn-primary btn-sm glyphicon glyphicon-plus"
					style="display: inline;">添加</button>
			</div>
		</form>
	</div>
	<br>
	<div class="container divcontainerstyle">
		<h2>查找单个学生</h2>
		<form action="../../servlet_querystudent_teacher">
			<div class="form-inline">
				<input type="text" name="querystudentnumber" placeholder="学号*"
					class="form-control"> <input type="text"
					name="querystudentname" placeholder="姓名*" class="form-control">
				<input type="text" name="queryclassroom" placeholder="班级*"
					class="form-control">
				<button type="submit"
					class="btn btn-primary btn-sm glyphicon glyphicon-search"
					style="display: inline;">查找</button>
			</div>
		</form>
	</div>
	<br>

	<div class="container">
		<h2>
			<strong>查找结果</strong>
		</h2>
		<table class="table table-striped table-bordered table-hover">
			<thead>
				<tr>
					<td>学号</td>
					<td>姓名</td>
					<td>班级</td>
					<td>绑定IP</td>
					<td>是否已提交答案</td>
					<td>参加的考试</td>
				</tr>
			</thead>
			<tbody>
				<%
					if (session.getAttribute("studentlist") != null) {
						Object obj = session.getAttribute("studentlist");
						if (obj instanceof List<?>) {
							/* 警告抑制 */
							@SuppressWarnings("unchecked")
							List<Student> studentlist = (List<Student>) (session.getAttribute("studentlist"));

							for (Student stu : studentlist) {
				%>
				<tr>
					<td><%=stu.getStudentnumber()%></td>
					<td><%=stu.getStudentname()%></td>
					<td><%=stu.getClassroom()%></td>
					<td><%=stu.getIpbinding() == null ? "未登录" : stu.getIpbinding()%></td>
					<td><%=stu.getSubmittime() == null ? "未提交" : "已提交"%></td>
					<td><%=stu.getExamname()%></td>
				</tr>
				<%
					}
						}
					}
					session.setAttribute("studentlist", null);
				%>
			</tbody>
		</table>
	</div>
</body>
</html>